
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zhrs/pages/login_verificationcode.dart';

class Login_shortmessage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _Login_shortmessage();
  }

}

class _Login_shortmessage extends State<Login_shortmessage>
{


  TextEditingController _phonenumbercontroller = new TextEditingController();
  alertDialog(BuildContext context,String msg){
    showDialog<Null>(
      context: context,
      barrierDismissible: false,
      child: new AlertDialog(
        title: new Text(
          '温馨提示',
          style: new TextStyle(
            color: Colors.black54,
            fontSize: 18.0,
          ),
        ),
        content: new Text(msg),
        actions: <Widget>[
          new FlatButton(
              onPressed: () {
                Navigator.pop(context);
              },
              child: new Text('确定')),
        ],
      ),
    );

  }

  @override
  Widget build(BuildContext context) {

   Text tr=new Text("dd");

    double mapViewHeight = MediaQuery.of(context).size.height;
    print("mapViewHeight:$mapViewHeight");
    double mapViewWidth = MediaQuery.of(context).size.width;
    print("mapViewWidth:$mapViewWidth");
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(backgroundColor: Colors.blue,),
           body:
               ListView(
                 children: <Widget>[
                   Column(
                     children: <Widget>[
                       Container(
                         width: mapViewWidth,
                         padding: EdgeInsets.fromLTRB(10 ,30,0,30),
                         child: Text(
                           "短信验证码登录",
                           style: TextStyle(fontSize: 25,color: Colors.blue),
                           textAlign: TextAlign.left,
                         ),
                       ),
                       Container(
                         child:Row(
                           children: <Widget>[
                             Container(
                               width: mapViewWidth*0.5,
                              padding: EdgeInsets.fromLTRB(10,0,0,0),
                               child:
                               TextField(
                                 textAlign: TextAlign.left,
                                 enabled: false,
                                 decoration: InputDecoration(
                                   hintText: "国家/地区 ",
                                   hintStyle:TextStyle(color: Colors.black,fontSize: 20),
                                 ),
                               ),
                             ),
                             Container(
                               width: mapViewWidth*0.5,
                               padding: EdgeInsets.fromLTRB(0,0,10,0),
                               child:
                               TextField(
                                 textAlign: TextAlign.right,
                                 enabled: false,
                                 decoration: InputDecoration(
                                     hintText: "中国大陆 ",
                                     hintStyle: TextStyle(color: Colors.grey,fontSize: 20)
                                 ),
                               ),
                             ),
                           ],
                         ) ,
                       ),
                       Container(

                         child:Row(
                           children: <Widget>[
                             Container(
                               width: mapViewWidth*0.3,
                               padding: EdgeInsets.fromLTRB(10,3,0,0),
                               child:
                               TextField(
                                 textAlign: TextAlign.left,
                                 enabled: false,
                                 decoration: InputDecoration(
                                   hintText: "+86",
                                   hintStyle:TextStyle(color: Colors.black,fontSize: 20),
                                 ),
                               ),
                             ),
                             Container(

                               width: mapViewWidth*0.7,
                               padding: EdgeInsets.fromLTRB(0,0,10,0),
                               child:
                               TextField(
                                 keyboardType: TextInputType.phone,
                                 textAlign: TextAlign.left,
                                 controller: _phonenumbercontroller,
                                 enabled: true,
                                 inputFormatters: <TextInputFormatter>[
                                   WhitelistingTextInputFormatter.digitsOnly,//只输入数字
                                 LengthLimitingTextInputFormatter(11)//限制长度
                                 ],
                                 decoration: InputDecoration(
                                     hintText: "请输入手机号 ",
                                     hintStyle: TextStyle(color: Colors.grey,fontSize: 20),
                                     suffixIcon: new IconButton(
                                       icon: new Icon(Icons.clear,
                                           color: Colors.black45),
                                       onPressed: () {
                                         _phonenumbercontroller.clear();
                                       },
                                     )
                                 ),
                               ),
                             ),
                           ],
                         ) ,
                       )
                       ,  new Container(
                         width: 420.0,
                         padding: EdgeInsets.fromLTRB(0,20,0,0),
                         child: new Card(
                           color: Colors.blue,
                           elevation: 0.0,
                           child: new FlatButton(
                             child: new Padding(
                               padding: new EdgeInsets.all(10.0),
                               child: new Text(
                                 '获取验证码',
                                 style: new TextStyle(
                                     color: Colors.white, fontSize: 16.0),
                               ),
                             ),
                             onPressed: () {
                             if(_phonenumbercontroller.text.isEmpty||_phonenumbercontroller.text.length<11)  {
                               alertDialog(context, "请输入正确手机号");
                               return;
                             }

                             Navigator.push(context, new MaterialPageRoute( builder: (context)
                                 {
                                return Login_verificationcode(_phonenumbercontroller.text);
                                 }

                             ));
                             },
                           ),
                         ),
                       ),
                     ],
                   ),
                 ],
               )
    );
  }
}